/* 
    对数器测试用例
*/
let genetateRandomArray = function (maxSize, maxValue) {
    let size = Math.floor((maxSize + 1) * Math.random());
    let arr = new Array(size);
    for (let index = 0; index < arr.length; index++) {
        arr[index] = Math.floor((maxValue + 1) * Math.random()) - Math.floor((maxValue + 1) * Math.random());
    }
    return arr;
};

let sortTest = function (maxSize, maxValue, testTimes, methodA, methodB) {
    for (let i = 0; i < testTimes; i++) {
        let arr1 = genetateRandomArray(maxSize, maxValue);
        let arr2 = [...arr1];
        let resA = methodA(arr1);
        let resB = methodB(arr2);
        if (JSON.stringify(resA) !== JSON.stringify(resB)) {
            return false;
        }
    }
    return true;
};

let { bubbleSort } = require('./冒泡排序');
let { selectSort } = require('./选择排序');
let { insertSort } = require('./插入排序');
let { mergeSort } = require('../排序2/归并排序');

console.log(sortTest(1000, 300, 10, insertSort, mergeSort));
